#pragma once

#include "Business/QueueContext.h"
#include "Utils/FastBlockQueue.h"
#include "Business/BollingerCalculator.h"
#include "afxcmn.h"
// CClassicBusinessDlg dialog

class ThreadManager;
class ClassicBusiness;
class ClassicBusinessArgument;
struct Command;

class CClassicBusinessDlg : public CDialog
{
	DECLARE_DYNAMIC(CClassicBusinessDlg)

public:
	CClassicBusinessDlg(ThreadManager& threadManager,CWnd* pParent = NULL);   // standard constructor
	virtual ~CClassicBusinessDlg();

// Dialog Data
	enum { IDD = IDD_CLASSIC_BUSINESS_DLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnInitDialog();

	afx_msg void OnBnClickedButtonAdd();
	afx_msg void OnLvnKeydownClassicBusinessList(NMHDR *pNMHDR, LRESULT *pResult);

	DECLARE_MESSAGE_MAP()

	CListCtrl m_businessList;
private:
	void AddBollingerManager();
	ClassicBusiness* AddBusiness(ClassicBusinessArgument const& argument);
	void InsertBusiness(ClassicBusiness* business);
	FT GetArgumentString(ClassicBusinessArgument const& argument);
	int GetCommandType(WORD key);
	void UpdateArgument(int index, QueueItem& item);

	void UpdateBusinessList(int index, ClassicBusinessArgument const& argument, int businessId);
	int GetBusinessIndex(ClassicBusiness* business) const;
private:
	ThreadManager& m_threadManager;
	FastBlockQueue::FastBlockQueuePtr m_uiQueue;
	QueueContext m_queueContext;

	BollingerCalculatorManager m_bollingerManager;
	std::map<ClassicBusiness*,int> m_businessIndexMap;
protected:
	virtual void OnOK();
	virtual void OnCancel();
public:
	afx_msg void OnMove(int x, int y);
	afx_msg void OnTimer(UINT_PTR nIDEvent);

	void OnCommand(Command const &cmd);
};
